load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "runaway",
    srcs = [
        "checker.go",
        "manager.go",
        "record.go",
        "syncer.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/resourcegroup/runaway",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/ddl",
        "//pkg/infoschema",
        "//pkg/kv",
        "//pkg/metrics",
        "//pkg/parser/ast",
        "//pkg/parser/terror",
        "//pkg/sessionctx",
        "//pkg/ttl/cache",
        "//pkg/ttl/sqlbuilder",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/chunk",
        "//pkg/util/dbterror/exeerrors",
        "//pkg/util/generic",
        "//pkg/util/logutil",
        "//pkg/util/sqlexec",
        "@com_github_gogo_protobuf//proto",
        "@com_github_jellydator_ttlcache_v3//:ttlcache",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/resource_manager",
        "@com_github_prometheus_client_golang//prometheus",
        "@com_github_tikv_client_go_v2//tikv",
        "@com_github_tikv_client_go_v2//tikvrpc",
        "@com_github_tikv_client_go_v2//util",
        "@com_github_tikv_pd_client//resource_group/controller",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "runaway_test",
    timeout = "short",
    srcs = [
        "checker_test.go",
        "record_test.go",
    ],
    embed = [":runaway"],
    flaky = True,
    shard_count = 2,
    deps = [
        "@com_github_stretchr_testify//assert",
        "@com_github_tikv_client_go_v2//util",
    ],
)
